unit uFrmPlateNumber;

interface

uses
  SysUtils, Classes, Variants, Windows, Messages, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, Buttons, StdCtrls, DLXButtons, uCxtForm;

type
  TFrmPlateNumber = class(TBaseForm)
    Panel1: TPanel;
    pnlCharTable: TPanel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    SpeedButton12: TSpeedButton;
    SpeedButton13: TSpeedButton;
    SpeedButton14: TSpeedButton;
    SpeedButton15: TSpeedButton;
    SpeedButton16: TSpeedButton;
    SpeedButton17: TSpeedButton;
    SpeedButton18: TSpeedButton;
    SpeedButton19: TSpeedButton;
    SpeedButton20: TSpeedButton;
    SpeedButton21: TSpeedButton;
    SpeedButton22: TSpeedButton;
    SpeedButton23: TSpeedButton;
    SpeedButton24: TSpeedButton;
    SpeedButton25: TSpeedButton;
    SpeedButton26: TSpeedButton;
    SpeedButton27: TSpeedButton;
    SpeedButton28: TSpeedButton;
    SpeedButton29: TSpeedButton;
    SpeedButton30: TSpeedButton;
    SpeedButton31: TSpeedButton;
    SpeedButton32: TSpeedButton;
    SpeedButton33: TSpeedButton;
    SpeedButton34: TSpeedButton;
    SpeedButton35: TSpeedButton;
    SpeedButton36: TSpeedButton;
    SpeedButton37: TSpeedButton;
    SpeedButton38: TSpeedButton;
    SpeedButton39: TSpeedButton;
    SpeedButton40: TSpeedButton;
    SpeedButton41: TSpeedButton;
    SpeedButton42: TSpeedButton;
    SpeedButton43: TSpeedButton;
    SpeedButton44: TSpeedButton;
    SpeedButton45: TSpeedButton;
    SpeedButton46: TSpeedButton;
    SpeedButton47: TSpeedButton;
    SpeedButton48: TSpeedButton;
    SpeedButton49: TSpeedButton;
    SpeedButton50: TSpeedButton;
    SpeedButton51: TSpeedButton;
    SpeedButton52: TSpeedButton;
    SpeedButton53: TSpeedButton;
    SpeedButton54: TSpeedButton;
    SpeedButton55: TSpeedButton;
    SpeedButton56: TSpeedButton;
    SpeedButton57: TSpeedButton;
    SpeedButton58: TSpeedButton;
    SpeedButton59: TSpeedButton;
    SpeedButton60: TSpeedButton;
    SpeedButton61: TSpeedButton;
    SpeedButton62: TSpeedButton;
    SpeedButton63: TSpeedButton;
    SpeedButton64: TSpeedButton;
    SpeedButton65: TSpeedButton;
    SpeedButton66: TSpeedButton;
    SpeedButton67: TSpeedButton;
    SpeedButton68: TSpeedButton;
    SpeedButton69: TSpeedButton;
    Panel2: TPanel;
    edtPlateNumber: TEdit;
    btnOK: TButton;
    btnCancel: TButton;
    procedure FormDeactivate(Sender: TObject);
    procedure OnSelectChar(Sender: TObject);
    procedure SpeedButton68Click(Sender: TObject);
    procedure SpeedButton69Click(Sender: TObject);
  end;

function PromptPlateNumber(const caption: string; var number: string): Boolean;

implementation

{$r *.dfm}

var
  FrmPlateNumber: TFrmPlateNumber;

function PromptPlateNumber(const caption: string; var number: string): Boolean;
begin
  if not Assigned(FrmPlateNumber) then
    FrmPlateNumber := TFrmPlateNumber.Create(Application);
  FrmPlateNumber.Caption := caption;
  FrmPlateNumber.edtPlateNumber.Text := number;
  FrmPlateNumber.edtPlateNumber.SelStart := Length(number);
  if FrmPlateNumber.ShowModal = mrOk then
  begin
    number := FrmPlateNumber.edtPlateNumber.Text;
    Result := True;
  end
  else Result := False;
end;

{ TFrmPlateNumber }

procedure TFrmPlateNumber.FormDeactivate(Sender: TObject);
begin
  Self.Hide;
end;

procedure TFrmPlateNumber.OnSelectChar(Sender: TObject);
begin
  edtPlateNumber.SelText := TSpeedButton(Sender).Caption;
end;

procedure TFrmPlateNumber.SpeedButton68Click(Sender: TObject);
begin
  if edtPlateNumber.SelText = '' then
  begin
    if edtPlateNumber.SelStart > 1 then
      edtPlateNumber.SelStart := edtPlateNumber.SelStart - 1
    else Exit;
    edtPlateNumber.SelLength := 1;
  end;
  edtPlateNumber.SelText := '';
end;

procedure TFrmPlateNumber.SpeedButton69Click(Sender: TObject);
begin
  edtPlateNumber.Text := '';
end;

end.
